<template>
  <div class="item">
    <img v-bind:src="imageItem.src" alt="">
    <div class="cover-back" v-if="imageItem.percent !== 100">
      <span>{{imageItem.percent}}%</span>
    </div>
    <div class="cover-front" v-if="imageItem.percent !== 100" v-bind:style="{height:(100-imageItem.percent)+'px'}">
      <span>{{imageItem.percent}}%</span>
    </div>
  </div>
</template>

<script>
  export default {
    name: "OSSUploadImage",
    props: {
      imageItem: Object,
    }
  }
</script>

<style scoped>
  .item {
    position: relative;
    box-sizing: border-box;
  }

  .item img {
    width: 100px;
    height: 100px;
    margin-top: 10px;
    margin-right: 10px;
    border: 1px solid #eee;
  }

  .item .cover-front {
    position: absolute;
    top: 11px;
    left: 1px;
    width: 100px;
    height: 50px;
    display: flex;
    align-items: center;
    justify-content: center;
    background: rgba(0, 0, 0, 0.3);
    white-space: nowrap;
    overflow: hidden;
    color: #fff;
  }

  .item span {
    position: absolute;
    top: 40px;
  }

  .item .cover-back {
    position: absolute;
    top: 11px;
    left: 1px;
    width: 100px;
    height: 100px;
    display: flex;
    align-items: center;
    justify-content: center;
  }
</style>
